home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1993 / MacHack 1993.toast / MacHack™ 1987-1992 / MacHack™ '87 / Utilities ƒ / Text Editors ƒ / MEDIT ƒ / Macros.mcr < prev    next >
Encoding:
Text File  |  1986-06-05  |  4.5 KB  |  231 lines  |  [TEXT/MEDT]

  1. **************************************************************************
  2. * This macro file is provided as a collection of useful example macros   *
  3. * You need MComp version 1.0D0 or later to compile this file.            *
  4. * Written           : 05.01.86 Matthias Aebi                             *
  5. * Last modification : 04.06.86 Matthias Aebi                             *
  6. **************************************************************************
  7.  
  8. * 1
  9. * this macro can be used to get irregulary spaced tabs.
  10. * write a dot in the first line of the window for every tab stop
  11. * that you would like to use
  12. "Tabs" {
  13.     Push;
  14.     Select(0,C.);
  15.     Push;
  16.     Find(".");
  17.     Select(0,C[ | 0,C.);
  18.     Copy;
  19.     Drop;
  20.     Pop;
  21.     Paste;
  22.     Insert(" ");
  23. };
  24.  
  25. * for use together with the following macros
  26. * 2
  27. "Save current Position/P" {
  28.     push;
  29. };
  30.  
  31. * 3
  32. * jumps back to the last saved position with macro 2
  33. * the stack can hold the last eight positions
  34. "Back to Position/B" {
  35.     select(L[,C[)!;
  36.     pop;
  37. };
  38.  
  39. * 4
  40. * moves the current selection to the position / selection
  41. * previously saved with macro 2
  42. "Move selection/M" {
  43.     cut;
  44.     pop;
  45.     paste!;
  46. };
  47.  
  48. * 5
  49. * copies the current selection to the position / selection
  50. * previously saved with macro 2
  51. "Copy selection/K" {
  52.     copy;
  53.     pop;
  54.     paste!;
  55. };
  56.  
  57. * 6
  58. * draw a line in the menu
  59. "-" {};
  60.  
  61. * 7
  62. * jump to bottom of file
  63. ! "Bottom" {
  64.     If Window(0) {
  65.         Sect(S$);
  66.         Select(L$,C$)!;
  67.     };
  68. };
  69.  
  70. * 8
  71. * jump to top of file
  72. "Top" {
  73.     SELECT(0,0)!;
  74. };
  75.  
  76. * 9
  77. * select all lines in the file
  78. "Select all" {
  79.     SELECT(0,0|L$,C$);
  80. };
  81.  
  82. * 10
  83. * move all lines in the current selection four positions to the left
  84. * by deleting the leftmost characters. do nothing for empty lines.
  85. "Move selection left/L" {
  86.     PUSH;
  87.     WHILE L. < L] {
  88.         SELECT(L.,0|L.,4);
  89.         CLEAR;
  90.         SELECT(L.+1,0)!;
  91.     };
  92.     SELECT(L[,0|L],0);
  93.     DROP;
  94. };
  95.  
  96. * 11
  97. * move all lines in the current selection to the right by inserting
  98. * a tab. do nothing for empty lines.
  99. "Move selection right/R" {
  100.     PUSH;
  101.     WHILE L. < L] {
  102.  
  103.         SELECT(L.,0);
  104.         IF NOT C$ = 0 {
  105.             INSERT("\t");
  106.         };
  107.         SELECT(L.+1,0)!;
  108.     };
  109.     SELECT(L[,0|L],0);
  110.     DROP;
  111. };
  112.  
  113. * 12
  114. * ask for a line number to jump to and do it
  115. "Jump to Line/J" {
  116.     prompt("Goto Line",#0);
  117.     select(#0-1,0|#0-1,C$)!;
  118. };
  119.  
  120. * 13
  121. * ask for a section number to jump to and do it
  122. "Jump to Section/S" {
  123.     prompt("Goto Section",#0);
  124.     sect(#0);
  125.     select(0,0)!;
  126. };
  127.  
  128. * 14
  129. * replace the shortcut to the left of the cursor position with
  130. * the appropriate string. to define shortcuts write them at the
  131. * top of the window followed by the string to insert. use one line for
  132. * each shortcut. separate string and shortcut by a blank.
  133. * examples: (define them without an asterik at the start of the window)
  134. * ilm I like Macintosh
  135. * gb Good bye
  136. *
  137. * if you type 'ilm' and then press command-g this will replace
  138. * 'ilm' with 'I like Macintosh'. 'gb' will be replaced by 'Good bye'
  139. "Glossary/G" {
  140.     Select(L.,C<|L.,C.);
  141.     Push;
  142.     Set($0,$S);
  143.     Select(0,0);
  144.     Find($0);
  145.  
  146.     If L. < L[ And C. = 0{
  147.         Select(L.,C:+1|L.,C$);
  148.         Copy;
  149.         Pop;
  150.         Paste;
  151.     }
  152.     Else {
  153.         Pop;
  154.         Select(L:,C:);
  155.     };
  156. };
  157.  
  158. * 15
  159. * scroll one screen down
  160. * if you have a Mac+ or a numeric keypad you may use shift-cursor-down
  161. "Page Down/D" 272 {
  162. * get screen height
  163.     Set(#9, L>-L<-1);
  164.     Select(L>+#9,C.)!;
  165. };
  166.  
  167. * 16
  168. * scroll one screen up
  169. * if you have a Mac+ or a numeric keypad you may use shift-cursor-up
  170. "Page Up/U" 277 {
  171. * get screen height
  172.     Set(#9, L>-L<-1);
  173.     Select(L<-#9,C.)!;
  174. };
  175.  
  176. * 17
  177. * replace all 'real' tabs by blank strings
  178. * this is useful to convert 'Edit'- to 'MEdit'-files
  179. "Replace tabs" {
  180.     SELECT(0,0);
  181.     WHILE FIND("\9")
  182.         INSERT("\t");
  183. };
  184.  
  185. "Append Section" {
  186.     Append;
  187. };
  188.  
  189. "-" {};
  190.  
  191. * the numbers define cursor keys on a Mac Plus / num Keypad
  192. "Cursor Up/2" 177 {
  193.     SELECT(L.-1,C.)!;
  194. };
  195.  
  196. "Cursor Down/A" 172 {
  197.     SELECT(L.+1,C.)!;
  198. };
  199.  
  200. "Cursor Right/W" 166 {
  201.     SELECT(L.,C.+1)!;
  202.     IF C. = C$ {
  203.         SELECT(L.+1,0)!;
  204.     };
  205. };
  206.  
  207. "Cursor Left/Q" 170 {
  208.     SELECT(L.,C.-1)!;
  209.     IF C. = 0 {
  210.         SELECT(L.-1,0);
  211.         SELECT(L.,C$);
  212.     };
  213. };
  214.  
  215. * this macro could be used to
  216. * redefinie shift-BS to 'delete to end of line' instead of 'delete right char'
  217. *251 {
  218. *    Select(L.,C.|L.,C$);
  219. *    Clear;
  220. *};
  221.  
  222. * swaps the to characters just before the current position
  223. * this macro is invoked by pressing option-BS. It has no menu entry
  224. 351 {
  225.     SELECT(L.,C.-1|L.,C.);
  226.     CUT;
  227.     SELECT(L.,C.-1);
  228.     PASTE;
  229.     SELECT(L.,C.+1);
  230. }.
  231.